package com.feihao.zhou.UDP.demo03GuangBo;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;

public class SendDemo {
    public static void main(String[] args) throws IOException {
        //创建发送端的socket对象.随机端口发送
        DatagramSocket ds = new DatagramSocket();
        Scanner scanner = new Scanner(System.in);
        //要发送的内容：
        while (true) {

            String s1 = "也一样";
            byte[] bytes = s1.getBytes();
            //要发送的ip地址:
            InetAddress address = InetAddress.getByName("255.255.255.255");
            //打包：内容，地址，端口号：
            DatagramPacket dp = new DatagramPacket(bytes,bytes.length,address,10000);

            //发送：
            ds.send(dp);
        }

        //关流：
        /*ds.close();*/

    }
}
